package com.twu.biblioteca;
import java.io.*;

public class UserInputHandler {
    BufferedReader bufferedReader;
    UserInputHandler(InputStream istream){
        this.bufferedReader = new BufferedReader( new InputStreamReader(istream));
    }

    public int getUserSelection() throws IOException{
        System.out.println("What option would you like to choose? ");
        return Integer.parseInt(bufferedReader.readLine());
    }

    public int getBookIndex() throws IOException{
        System.out.println("Enter the book number that you want to reserve: ");
        return Integer.parseInt(bufferedReader.readLine());
    }

    public int readUsernameRequest() throws IOException {
        String userInputName = bufferedReader.readLine();
        return Integer.parseInt(userInputName.replaceAll("[^0-9]", ""));
    }

    public String readPasswordRequest() throws IOException {
        return bufferedReader.readLine();
    }
}
